package com.psytech.app.task.entity.implementation;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.hibernate.validator.NotNull;

@Entity
@Table(name = "comment")
public class Comment implements Serializable, STMEntity {

	/**
	 * 
	 */
	private static final long serialVersionUID = 501455716704607822L;

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private Integer id;

	@NotNull
	private String uid;

	@NotNull
	private String text;

	@NotNull
	@Temporal(value = TemporalType.TIMESTAMP)
	private Date creationDate;

	@ManyToOne(targetEntity = User.class)
	@JoinColumn(name = "writerId")
	private User writer;

	@ManyToOne(targetEntity = Task.class)
	@JoinColumn(name = "taskId")
	private Task task;

	public Integer getId() {
		return this.id;
	}

	public void setId(final Integer id) {
		this.id = id;
	}

	/**
	 * A d�finir par la couche m�tier.
	 * 
	 * @param uid
	 *            Universal ID de la t�che.
	 */
	public String getUid() {
		return this.uid;
	}

	public void setUid(final String uid) {
		this.uid = uid;
	}

	public String getText() {
		return this.text;
	}

	public void setText(final String text) {
		this.text = text;
	}

	public Date getCreationDate() {
		return this.creationDate;
	}

	public void setCreationDate(final Date creationDate) {
		this.creationDate = creationDate;
	}

	public User getWriter() {
		return this.writer;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.psytech.app.task.entity.CommentInterface#setWriter(com.psytech.app
	 * .task.entity.User)
	 */
	public void setWriter(final User writer) {
		this.writer = writer;
	}

	public Task getTask() {
		return this.task;
	}

	public void setTask(final Task task) {
		this.task = task;
	}
}
